home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / Xpm / pixmap / xpm.h < prev   
C/C++ Source or Header  |  1994-08-01  |  7KB  |  231 lines

  1. /* Copyright 1990-92 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * xpm.h:                                                                      *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Include file                                                               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #ifndef XPM_h
  12. #define XPM_h
  13.  
  14. #ifdef VMS
  15. #include "decw$include:Xlib.h"
  16. #else
  17. #include <X11/Xlib.h>
  18. #endif
  19.  
  20. /* let's define Pixel if it is not done yet */
  21. #ifndef _XtIntrinsic_h
  22. typedef unsigned long    Pixel;        /* Index into colormap        */
  23. #endif
  24.  
  25. /* Return ErrorStatus codes:
  26.  * null     if full success
  27.  * positive if partial success
  28.  * negative if failure
  29.  */
  30.  
  31. #define XpmColorError    1
  32. #define XpmSuccess       0
  33. #define XpmOpenFailed   -1
  34. #define XpmFileInvalid  -2
  35. #define XpmNoMemory     -3
  36. #define XpmColorFailed  -4
  37.  
  38.  
  39. typedef struct {
  40.     char *name;                /* Symbolic color name */
  41.     char *value;            /* Color value */
  42.     Pixel pixel;            /* Color pixel */
  43. }      XpmColorSymbol;
  44.  
  45. typedef struct {
  46.     char *name;                /* name of the extension */
  47.     unsigned int nlines;        /* number of lines in this extension */
  48.     char **lines;            /* pointer to the extension array of 
  49.                        strings */
  50. }      XpmExtension;
  51.  
  52. typedef struct {
  53.     unsigned long valuemask;        /* Specifies which attributes are
  54.                      * defined */
  55.  
  56.     Visual *visual;            /* Specifies the visual to use */
  57.     Colormap colormap;            /* Specifies the colormap to use */
  58.     unsigned int depth;            /* Specifies the depth */
  59.     unsigned int width;            /* Returns the width of the created
  60.                      * pixmap */
  61.     unsigned int height;        /* Returns the height of the created
  62.                      * pixmap */
  63.     unsigned int x_hotspot;        /* Returns the x hotspot's
  64.                      * coordinate */
  65.     unsigned int y_hotspot;        /* Returns the y hotspot's
  66.                      * coordinate */
  67.     unsigned int cpp;            /* Specifies the number of char per
  68.                      * pixel */
  69.     Pixel *pixels;            /* List of used color pixels */
  70.     unsigned int npixels;        /* Number of pixels */
  71.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  72.                      * override */
  73.     unsigned int numsymbols;        /* Number of symbols */
  74.     char *rgb_fname;            /* RGB text file name */
  75.     unsigned int nextensions;        /* number of extensions */
  76.     XpmExtension *extensions;        /* pointer to array of extensions */
  77.  
  78.     /* Infos */
  79.     unsigned int ncolors;        /* Number of colors */
  80.     char ***colorTable;            /* Color table pointer */
  81.     char *hints_cmt;            /* Comment of the hints section */
  82.     char *colors_cmt;            /* Comment of the colors section */
  83.     char *pixels_cmt;            /* Comment of the pixels section */
  84.     unsigned int mask_pixel;        /* Transparent pixel's color table
  85.                      * index */
  86.     /* Color Allocation Directives */
  87.     unsigned int exactColors;        /* Only use exact colors for visual */
  88.     unsigned int closeness;        /* Allowable RGB deviation */
  89.  
  90. }      XpmAttributes;
  91.  
  92. /* Xpm attribute value masks bits */
  93. #define XpmVisual       (1L<<0)
  94. #define XpmColormap       (1L<<1)
  95. #define XpmDepth       (1L<<2)
  96. #define XpmSize           (1L<<3)    /* width & height */
  97. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  98. #define XpmCharsPerPixel   (1L<<5)
  99. #define XpmColorSymbols       (1L<<6)
  100. #define XpmRgbFilename       (1L<<7)
  101. #define XpmInfos       (1L<<8)    /* all infos members */
  102. #define XpmExtensions      (1L<<10)
  103.  
  104. #define XpmReturnPixels       (1L<<9)
  105. #define XpmReturnInfos       XpmInfos
  106. #define XpmReturnExtensions XpmExtensions
  107.  
  108. #define XpmExactColors     (1L<<11)
  109. #define XpmCloseness       (1L<<12)
  110.  
  111. /*
  112.  * minimal portability layer between ansi and KR C 
  113.  */
  114.  
  115. /* forward declaration of functions with prototypes */
  116.  
  117. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  118.  /* ANSI || C++ */
  119. #define FUNC(f, t, p) extern t f p
  120. #define LFUNC(f, t, p) static t f p
  121. #else                    /* K&R */
  122. #define FUNC(f, t, p) extern t f()
  123. #define LFUNC(f, t, p) static t f()
  124. #endif                    /* end of K&R */
  125.  
  126.  
  127. /*
  128.  * functions declarations
  129.  */
  130.  
  131. #ifdef __cplusplus
  132. extern "C" {
  133. #endif
  134.  
  135.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  136.                     Drawable d,
  137.                     char **data,
  138.                     Pixmap *pixmap_return,
  139.                     Pixmap *shapemask_return,
  140.                     XpmAttributes *attributes));
  141.  
  142.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  143.                     char ***data_return,
  144.                     Pixmap pixmap,
  145.                     Pixmap shapemask,
  146.                     XpmAttributes *attributes));
  147.  
  148.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  149.                     Drawable d,
  150.                     char *filename,
  151.                     Pixmap *pixmap_return,
  152.                     Pixmap *shapemask_return,
  153.                     XpmAttributes *attributes));
  154.  
  155.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  156.                        char *filename,
  157.                        Pixmap pixmap,
  158.                        Pixmap shapemask,
  159.                        XpmAttributes *attributes));
  160.  
  161.     FUNC(XpmCreateImageFromData, int, (Display *display,
  162.                        char **data,
  163.                        XImage **image_return,
  164.                        XImage **shapemask_return,
  165.                        XpmAttributes *attributes));
  166.  
  167.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  168.                        char ***data_return,
  169.                        XImage *image,
  170.                        XImage *shapeimage,
  171.                        XpmAttributes *attributes));
  172.  
  173.     FUNC(XpmReadFileToImage, int, (Display *display,
  174.                    char *filename,
  175.                    XImage **image_return,
  176.                    XImage **shapeimage_return,
  177.                    XpmAttributes *attributes));
  178.  
  179.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  180.                       char *filename,
  181.                       XImage *image,
  182.                       XImage *shapeimage,
  183.                       XpmAttributes *attributes));
  184.  
  185.     FUNC(XpmReadFileToData, int, (char *filename, char  ***data_return));
  186.     FUNC(XpmAttributesSize, int, ());
  187.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  188.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions, int nextensions));
  189.  
  190. #ifdef __cplusplus
  191. }                    /* for C++ V2.0 */
  192.  
  193. #endif
  194.  
  195.  
  196. /* backward compatibility */
  197.  
  198. /* for version 3.0c */
  199. #define XpmPixmapColorError  XpmColorError
  200. #define XpmPixmapSuccess     XpmSuccess
  201. #define XpmPixmapOpenFailed  XpmOpenFailed
  202. #define XpmPixmapFileInvalid XpmFileInvalid
  203. #define XpmPixmapNoMemory    XpmNoMemory
  204. #define XpmPixmapColorFailed XpmColorFailed
  205.  
  206. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  207.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  208. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  209.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  210.  
  211. /* for version 3.0b */
  212. #define PixmapColorError  XpmColorError
  213. #define PixmapSuccess     XpmSuccess
  214. #define PixmapOpenFailed  XpmOpenFailed
  215. #define PixmapFileInvalid XpmFileInvalid
  216. #define PixmapNoMemory    XpmNoMemory
  217. #define PixmapColorFailed XpmColorFailed
  218.  
  219. #define ColorSymbol XpmColorSymbol
  220.  
  221. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  222.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  223. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  224.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  225. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  226.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  227. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  228.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  229.  
  230. #endif
  231.